import re
import numpy as np

class text:
    def pick_data(self,message,dataname):
        mes=re.split(r'[;:]',message)  # 解出分类
        data=mes[mes.index('Data')+1]    # 提取Data
        datas=re.split(r'[(&)]',data)   # 分割参数
        dataset=datas[datas.index(dataname)+1].split(',')   # 提取参数
        numb=[float(i) for i in dataset]
        return np.array(numb)

    def pick_conm(self,message,comm):
        mes = re.split(r'[;:]', message)  # 解出分类
        conm = mes[mes.index('Command') + 1]  # 提取Data
        conms = re.split(r'[(&)]', conm)  # 分割参数
        conmset = conms[conms.index(comm)+1].split(',')  # 提取参数
        numb = [float(i) for i in conmset]
        return np.array(numb)

    def pick_act(self,message,actm):
        mes = re.split(r'[;:]', message)  # 解出分类
        act = mes[mes.index('Actor') + 1]  # 提取Data
        acts = re.split(r'[(&)]', act)  # 分割参数
        actset = acts[acts.index(actm)+1].split(',')  # 提取参数
        numb = [float(i) for i in actset]
        return np.array(numb)